<?php

$css = array();
$javascript = array();

flep_structure($structure, 'entrada');

function include_page($structure) {
  $user = &$_SESSION['user'];
  $edit = isset($_POST['id']) && $_POST['id'] !== '';
?>
  <b><?php echo (!$edit?'Nuevo ':'')?>Curso</b>
  <br><br>
  Seleccione una entrada:<br>
  <br>
  <table class="list" style="width: 415px; padding: 0px 15px;">
    <thead style="float:left;">
      <tr>
        <th style="width: 90px; padding: 0px">Entrada</th>
        <th style="width: 90px; padding: 0px">Inicio</th>
        <th style="width: 90px; padding: 0px">Cierre</th>
        <th style="width: 90px; padding: 0px">Programa</th>
        <th style="width: 40px; padding: 0px"><input type="hidden" id="entrada_selected" value=""></th>
      </tr>
    </thead>
    <tbody style="overflow-y: scroll; width: 415px; max-height: 280px; float:left;">
      <?php
        if(flep_search_all($structure)){
          foreach($structure['data'] as &$entrada) {
            printf("<tr><td style='width: 90px; padding: 0px'>%s</td>", $entrada['entrada']);
            printf("<td style='width: 90px; padding: 0px'>%s</td>", $entrada['fecha_inicio']);
            printf("<td style='width: 90px; padding: 0px'>%s</td>", $entrada['fecha_cierre']);
            printf("<td style='width: 90px; padding: 0px'>%s</td>", $entrada['programa']);
            printf("<td style='width: 40px; padding: 0px'><input type='radio' value='%s' name='entry' onclick='E(\"entrada_selected\").value = this.value'></td>", flep_encode($entrada['id']));
          }
        }
      ?>
    </tbody>
  </table>
  <br><br>
  <div style="text-align: right;"><input type="submit" onclick="flep_add_curso('<?php echo $edit?$_POST['id']:'null'; ?>', E('entrada_selected').value, true)" value="Seleccionar"></div>
</form>
<?php
}

?>
